#if !defined(AFX_MAINORDERPANEL_H__85E07A36_7F5E_41B8_B634_5D3DACF755B5__INCLUDED_)
#define AFX_MAINORDERPANEL_H__85E07A36_7F5E_41B8_B634_5D3DACF755B5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MainOrderPanel.h : header file
//
#include "CurPriceGrid.h"
#include "OrderPanelGrid.h"
#include "OrderStateGrid.h"
#include "TickTableGrid.h"
#include "CurPriceManager.h"
#include "resource.h"
#include "ResizeDlg.h"
#include "PriceEventSink.h"
#include "CurPriceInfo.h"
#include "EventSink.h"
#include "afxwin.h"
#include "SymbolManager.h"
#include "AccountManager.h"
#include "OrderManager.h"
#include "ResizableDialog.h"
#include "FillGrid.h"
#include "OptionGrid.h"
#include "GridCountDif.h"
#include "afxcmn.h"
#include "TotalGrid.h"
#include "IniFile.h"
/////////////////////////////////////////////////////////////////////////////
// CMainOrderPanel dialog

class CMainOrderPanel : public CResizableDialog
{
// Construction
public:
	CIniFile       m_IniMgr;
	CMainOrderPanel(CWnd* pParent = NULL);   // standard constructor

	COrderPanelGrid m_OrderPanelGrid;
	COrderStateGrid m_OrderStateGrid;
	CTickTableGrid  m_TickTableGrid;
	CCurPriceGrid   m_CurPriceGrid;
	CFillGrid       m_FillGrid;
	COptionGrid     m_OptionGrid;
	CGridCountDif   m_CountDifGrid;
	CTotalGrid      m_TotalGrid;

	//CCurPriceManager m_CurPriceMgr;

	vectorSymBolManager m_SymbolMgrList;
	CSymbolManager* m_SymbolMgr;
	CSymbolInfo* m_CurSymbol;
	CAccountManager* m_AccountMgr;
	CAccountInfo* m_CurAccount;

	COrderManager* m_OrderManager;

	int m_TimerID;


	void ResetTopVal(double a_TopVal);
	void AddSymbolToCombo(wstring a_String);
	void InitOptionMonth();

	BOOL m_bInit;

	void PutOrder(CString a_Val, IPositionType a_PositionType);
	void CancelOrder(CString a_Val, IPositionType a_PositionType);
	void ModifyOrder(CString a_Val, CString a_NewVal, IPositionType a_PositionType);

	void CancelOrder(CString a_Val, IPositionType a_PositionType, OrderVector* a_OrderVector);
	void ModifyOrder(CString a_Val, CString a_NewVal, IPositionType a_PositionType, OrderVector* a_OrderVector);

	void ShowOrders();

	void ShowCurValues();

	void RefreshPosition(CPositionInfo* a_Posi);
	void RefreshAccount(CAccountInfo* a_Acc);

	void SetStrikes(int a_Index);
	void ChangeFutureSymbol(CString a_SymbolCode);
	void RefreshOrderPanelGrid();
	void ChangeOptionSymbol(CString a_OptionCode);

	void SetOrderAmountText(CString a_Text);

	void OnPriceChanged();
	void OnQuoteChanged();
	void OnTickChanged();
	void RefreshPosition();

	void ShowNewOrder(COrderInfo* a_NewOrder, COrderInfo* a_PrevOrder);
	void ShowConfirmOrder(COrderInfo* a_ConfirmOrder);

private:

	void SelectAccountByIndex(int a_Index);
	CFont m_CtrlFont;
	CString m_strCode;
	IGxServer m_Server;

	CString m_strAccount;


	void InitAccount();
	void InitSymbol();

	void PutOrder(CString a_Code, CString pType, CString OType, long Qty, double OrderP, CString Ocls, long OrdNum);



// Dialog Data
	//{{AFX_DATA(CMainOrderPanel)
	enum { IDD = IDD_MAIN_ORDER };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMainOrderPanel)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
		
	int m_CurRow;
	void ShowCenterValues();
	// Generated message map functions
	//{{AFX_MSG(CMainOrderPanel)
	virtual BOOL OnInitDialog();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnClose();
	afx_msg void OnBtnExpandR();
	afx_msg void OnBtnExpandL();
	//afx_msg LRESULT OnCurPriceUpdated(WPARAM wParam, LPARAM lParam);
	//afx_msg LRESULT OnQuoteUpdated(WPARAM wParam, LPARAM lParam);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

	void RepositionCurVal();
public:
	afx_msg void OnBnClickedBtnCenter();
	CComboBox m_ComboAccount;
	CComboBox m_ComboProduct;
	afx_msg void OnSelchangeComboAccount();
	afx_msg void OnSelchangeComboProduct();
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	afx_msg void OnSelchangeComboOptionMonths();
	CComboBox m_ComboOptionMonths;
	CButton m_CheckReserveTick;
	CButton m_CheckTick;
	CSpinButtonCtrl m_SpinLimit;
	CSpinButtonCtrl m_SpinReserveTick;
	CStatic m_StaticOptionMonth;
	CEdit m_EditTick;
	CStatic m_StaticOrderPanel;
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINORDERPANEL_H__85E07A36_7F5E_41B8_B634_5D3DACF755B5__INCLUDED_)
